﻿using UnityEngine;
using UnityEditor;

namespace SocketWeaver.FPhysics2D.CustomUnityEditor
{
    [CustomEditor(typeof(FRigidbody2D))]
    public class FRigidbody2DInspector : Editor
    {
        FRigidbody2D editObject;

        private void OnEnable()
        {
            editObject = target as FRigidbody2D;
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();


            EditorGUILayout.PropertyField(serializedObject.FindProperty("_bodyType"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_linearDrag"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_angularDrag"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_gravityScale"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("_fixedRotation"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("externalId"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("_collisionEvents"));


            if (serializedObject.FindProperty("_collisionEvents").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_OnCollisionEnter"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_OnCollisionStay"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_OnCollisionExit"));
            }

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("sceneIndex"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_bodyId"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_mass"));
            EditorGUI.EndDisabledGroup();


            serializedObject.ApplyModifiedProperties();
        }
    }

}